package com.portal.innovation.sysController;


import com.portal.innovation.utils.PageUtils;
import com.portal.innovation.common.R;
import com.portal.innovation.pojo.Faq;
import com.portal.innovation.service.FaqService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.HashMap;

@RestController
@RequestMapping("faq")
public class FaqController {

    @Autowired
    private FaqService faqService;

    @PostMapping("list")
    public R save(@RequestBody HashMap params) {
        PageUtils page = faqService.queryPage(params);
        return R.ok().put("page", page);
    }

    @PostMapping("save")
    public R save(@RequestBody Faq faq) {
        faqService.save(faq);
        return R.ok();
    }

    @DeleteMapping("delete")
    public R save(@RequestBody Integer[] ids) {
        faqService.removeByIds(Arrays.asList(ids));
        return R.ok();
    }

    @PostMapping("update")
    public R update(@RequestBody Faq faq) {
        faqService.updateById(faq);
        return R.ok();
    }

    @GetMapping("/info/{id}")
    public R info(@PathVariable("id") Integer id){
        Faq faq = faqService.getById(id);
        return R.ok().put("faq", faq);
    }
}
